package com.yunfeisoft.business.model;

import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;
import com.yunfeisoft.common.utils.DateUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * ClassName: Receipt
 * Description: 收款单
 *
 * @Author: Jackie liu
 * Date: 2020-04-01
 */
@Entity
@Table(name = "TT_RECEIPT")
public class Receipt extends BaseModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 老人id
     */
    @Column
    private String elderId;

    /**
     * 开始日期
     */
    @Column
    private Date beginDate;

    /**
     * 结束日期
     */
    @Column
    private Date endDate;

    /**
     * 床位费
     */
    @Column
    private BigDecimal bedAmount;

    /**
     * 护理费
     */
    @Column
    private BigDecimal nurseAmount;

    /**
     * 生活费
     */
    @Column
    private BigDecimal liveAmount;

    /**
     * 其他费用
     */
    @Column
    private BigDecimal otherAmount;

    /**
     * 总费用
     */
    @Column
    private BigDecimal totalAmount;

    /**
     * 备注
     */
    @Column
    private String remark;

    /**
     * 入账状态
     */
    @Column
    private Integer status;

    /**
     * 付款方式
     */
    @Column
    private Integer payType;

    @TransientField
    private String elderName;

    public String getPayTypeStr() {
        return ReceiptPayTypeEnum.valueOf(payType);
    }

    public String getStatusStr() {
        return ReceiptStatusEnum.valueOf(status);
    }

    public String getBeginDateStr() {
        if (beginDate != null) {
            return DateUtils.dateToString(beginDate);
        }
        return null;
    }

    public String getEndDateStr() {
        if (endDate != null) {
            return DateUtils.dateToString(endDate);
        }
        return null;
    }

    public String getElderId() {
        return elderId;
    }

    public void setElderId(String elderId) {
        this.elderId = elderId;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public BigDecimal getBedAmount() {
        return bedAmount;
    }

    public void setBedAmount(BigDecimal bedAmount) {
        this.bedAmount = bedAmount;
    }

    public BigDecimal getNurseAmount() {
        return nurseAmount;
    }

    public void setNurseAmount(BigDecimal nurseAmount) {
        this.nurseAmount = nurseAmount;
    }

    public BigDecimal getLiveAmount() {
        return liveAmount;
    }

    public void setLiveAmount(BigDecimal liveAmount) {
        this.liveAmount = liveAmount;
    }

    public BigDecimal getOtherAmount() {
        return otherAmount;
    }

    public void setOtherAmount(BigDecimal otherAmount) {
        this.otherAmount = otherAmount;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getElderName() {
        return elderName;
    }

    public void setElderName(String elderName) {
        this.elderName = elderName;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public enum ReceiptStatusEnum {

        WAITING(1, "待入账"),
        ACCEPT(2, "已入账");

        private int value;
        private String label;

        private ReceiptStatusEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (ReceiptStatusEnum loop : ReceiptStatusEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

    }

    public enum ReceiptPayTypeEnum {

        CASH(1, "现金"),
        CARD(2, "刷卡"),
        TRANSFER_ACCOUNTS(3, "转账"),
        OTHER(4, "其他");

        private int value;
        private String label;

        private ReceiptPayTypeEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (ReceiptPayTypeEnum loop : ReceiptPayTypeEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

    }
}